package linguo.player;

import linguo.Data;
import linguo.Game;
import linguo.level.Board;

public class RobotMilitar extends Robot {

	protected int municion, max_municion;
	// El tiempo en el que se disparo por ultima vez
	protected long lastFire = 0;
	// El intervalo (en ms) que se permite disparar
	protected long firingInterval = 200;

	public RobotMilitar(Game game, Board board, int x, int y) {
		super(game, board, x, y);
		this.max_nafta = 125;
		municion = 10;
		max_municion = 30;

		image_forward = Data.SPRITE_SHEET.grabImage(0, 0);
		image_down = Data.SPRITE_SHEET.grabImage(1, 0);
		image_left = Data.SPRITE_SHEET.grabImage(2, 0);
		image_right = Data.SPRITE_SHEET.grabImage(3, 0);
		image = image_forward;
	}

	public void tryToFire() {
		if (municion > 0) {
			// realiza un checkeo para impedir 'spammear' disparos
			if (System.currentTimeMillis() - lastFire < firingInterval) return;
			lastFire = System.currentTimeMillis();

			new Bullet(game, board, x, y, o, this);
			municion--;
		}
	}

	public void incrementarMunicion(int m) {
		municion += m;
		if (municion > max_municion) municion = max_municion;
	}

	public int getMunicion() {
		return municion;
	}

	public int getMaxMunicion() {
		return max_municion;
	}

}
